<?php

namespace addons\cloud_market\utils;

/**
 * LocalApi 工具类
 */
class LocalApi
{
    public $site_id = 0;
    public $site_token = '';

    public $url = '';

    public function __construct($site)
    {
        $this->site_id = $site['id'];
        $this->site_token = $site['token'];
        // TODO 临时修改
//        $this->url = 'http://' . $site['domain'] . '/adminapi/cloud_local/';
        $this->url = "http://vue3.dkgs.cc/adminapi/cloud_local/";
    }

    public function getPlatformMsg($token, $type)
    {
        $param = [
            'token' => $token,
            'type' => $type
        ];
        return $this->httpPost('getPlatformMsg', $param);
    }

    public function httpPost($path, $param = [])
    {
        $param = array_merge($param, ['site_id' => $this->site_id, 'site_token' => $this->site_token]);
        $res = httpPost($this->url . $path, $param);
        var_dump($res);
        return json_decode($res, true);
    }
}
